<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserLearnVideoLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_learn_video_logs', function (Blueprint $table) {
            $table->id();
            $table->integer('userId', false, true)->index()->comment('用户ID');
            $table->integer('learnVideoId', false, true)->index()->comment('视频课程ID');
            $table->integer('lastWatchLearnVideoSectionId', false, true)->index()->nullable()->comment('最后看的小节id');
            $table->integer('watchSectionCount')->default(0)->index()->comment('已看小节（视频）数量');
            $table->text('data')->nullable()->comment('记录，以章节划分');
            $table->tinyInteger('getType')->nullable()->index()->comment('资源获得类型:1=订单、2=激活码、3=限免、4=其他、5=专栏激活、6=专栏购买');
            $table->tinyInteger('isTry')->nullable()->index()->comment('是否限免:1=是、0=否');
            $table->dateTime('getAt')->index()->comment('获得该资源时间');
            $table->dateTime('expireAt')->nullable()->index()->comment('资源过期时间');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE user_learn_video_logs comment '用户视频课程记录'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_learn_video_logs');
    }
}
